package org.example.mirai

import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.BotFactory
import net.mamoe.mirai.alsoLogin
//import net.mamoe.mirai.newBot
import net.mamoe.mirai.utils.BotConfiguration.MiraiProtocol.ANDROID_PAD

/*
suspend fun main() {
    val bot = BotFactory.newBot(123456, "").alsoLogin()

    bot.getFriend(123456789)?.sendMessage("Hello, World!")
}
*/

fun byteArrayOfInts(vararg ints: Int) = ByteArray(ints.size) { pos -> ints[pos].toByte() }

object WithConfiguration {
    val md5 = byteArrayOfInts(0xf2, 0x92, 0xdd, 0xf8, 0x90, 0x63, 0x34, 0x78, 0x09, 0x08, 0x4e, 0xfd, 0xc1, 0xe6, 0x3e, 0xb5)

    @JvmStatic
    fun main(args: Array<String>): Unit = runBlocking {
        // 使用自定义配置
        val bot = BotFactory.newBot(qq=1846326091, passwordMd5=md5) {
            fileBasedDeviceInfo() // 使用 device.json 存储设备信息
            protocol = ANDROID_PAD // 切换协议
        }.alsoLogin()

        bot.getFriend(1846326091)?.sendMessage("Hello, World!")
    }
}